package com.coocaa.aries.jmeter.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author : bijiahao
 * @date : 2019/5/30.
 * @description: 文件工具
 */
@Slf4j
public class FileUtil {

    public static void copyFile(String resourceFile) {
        String classPath = PathUtil.getClassPath();
        String targetPath = classPath + resourceFile;
        log.info("\n====targetPath: " + targetPath);
        File targetFile = new File(targetPath);
        if (!targetFile.exists()) {
            InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceFile);
            try {
                FileUtils.copyInputStreamToFile(stream, targetFile);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
